package fun.xinnix.collection.list;

import java.util.*;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

public class ListTest {
    private static final Log log = LogFactory.get();

    public static void main(String[] args) {
        List<Integer> list = selfDividingNumbers(1, 22);
        log.info("list,{}", list);
    }

    public static List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> list = new ArrayList<>();
        for (int i = left; i <= right; i++) {
            int tempNum = i;
            boolean isResult = true;
            if (i == 0)
                continue;
            while (tempNum > 0) {
                int div = tempNum % 10;
                log.info("div,{},temp,{}", div, tempNum);
                if (div == 0) {
                    isResult = false;
                    break;
                }
                int div2 = i % div;
                log.info("div2,{}",  div2);
                if (div2 != 0) {
                    isResult = false;
                    break;
                }
                tempNum /= 10;
                log.info("tmepRes,{}", tempNum);
            }
            if (isResult) {
                list.add(i);
            }
        }
        return list;
    }
}
